app.controller("userUpd",function($scope,$uibModal,$rootScope,del,$state,get,pos,post,$stateParams,Md5){
	$scope.search=function(){
		 get.list('user/findOne',{uId:$stateParams.id}).then(function(e) {
		  	$scope.name=e.uAccount
		  	$scope.pwd=e.uPassword
		  	$scope.list=e
		  	console.log(e)
		  }); 
	}
	/**
	 * 提交
	 */
	$scope.submitForm=function(){
		var arr=''
		angular.forEach($scope.list.roles,function(o){
			if (o.checked==true) {
			     arr+=o.id+","
			} 
			
		})
		var param={
			userRoles:arr,
			uAccount:$scope.name,
			uPassword:Md5.hex_md5($scope.pwd),
			uId:$stateParams.id
		}
		
		console.log(param)
			post.list("user/update",param).then(function(e){
				$rootScope.open(e);
				$state.go("home.user",null,{
					     		reload:true
					     	})
			})
		
		
		
		
	}
	$scope.search()

})
